﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BlockOS.Server
{
    public abstract class ScheduledModule : IServerModule
    {
        private int timer;
        private readonly int schedule;

        public ScheduledModule(int schedule)
        {
            this.schedule = schedule;
            timer = schedule;
        }

        public abstract void ScheduledTick();

        public virtual void Tick()
        {
            if (timer++ >= schedule)
            {
                ScheduledTick();
                timer = 0;
            }
        }

        public virtual void Update(TimeSpan deltaTime) { }

        public virtual void Deinit() { }
        public virtual void Init() { }
    }
}
